<%--
  Created by IntelliJ IDEA.
  User: Damon
  Date: 2018/4/20
  Time: 12:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>

    <title>Title</title>

</head>
<script src="jquery/jquery.min.js"></script>
<script src="layui/layui.js"></script>
<link rel="stylesheet" href="layui/css/layui.css">
<body >

     <table style="color:white;" class="layui-hide" id="stest"></table>

     <div id="laypage"></div>


      <div style="width: 200px;height: 150px;display: none"  id="divs" >


      </div>

     <div style="padding: 15px;" id="index_loaddiv">


     </div>



     <script>



    layui.use('laypage', function(){
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            //每页显示几条
            limit:5,
// 			  theme:"red",
            //
            groups:5,
// 			  prev:"←",
// 			  next:"→",
            elem: 'laypage',
            count:10, //数据总数，从服务端得到
            jump: function(obj, first){

                //当前页
                tableinit(obj.curr,obj.limit)
            }
        });
    });


    function  tableinit(curr,limit) {

        layui.use('table', function(){
            var table = layui.table;
            table.render({
                elem: '#stest'
                ,id: "table"
                ,url:'http://localhost:8088/user/getShopCarList'
                ,cellMinWidth: 200 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                ,cols: [[
                    {field:'shopid', width:"10%", title: 'ID', sort: true},
                    {field:'shopname', width:"20%", title: '标题', sort: true},
                    {field:'shopcount', width:"10%", title: '路径', sort: true},
                    {field:'shopprice', width:"10%", title: '操作', sort: true},
                    {field:'wy', width:"10%", title: '操作', sort: true}
                ]],
                where:{
                    curr:curr,
                    limit:limit,
                }
            });
        });
    }
     function shopPingCar(shopid){

         $.ajax({
             url:"http://localhost:8088/user/ShoppingCar",
             data:{shopid:shopid,shopcount:1},
             dataType:"text",
             async:false,
             type:"GET",
             success:function(result){

              result =     eval("("+result+")")
                location.href="http://localhost:8080/show.jsp?id="+result.id

             }

         })



         }

     function details(shopid){

        $.ajax({
            url:"http://localhost:8088/user/quercommodityByid",
            data:{shopid:shopid},
            dataType:"text",
            async:false,
            type:"GET",
            success:function(result){

                $("#divs").html(result)

            }

        })


         layer.open({
             move:false,   //允许拖拽
             fixed:true,
             resize:false,   //禁止改变大小
             type: 1//此处以iframe举例
             ,title: '商品用户详情'
             ,area: ['auto', 'auto']
             ,shade: 0
             ,maxmin: false
             ,offset: [
                 "50%","50%"
             ]
             ,content: $("#divs").html()
             ,btn: ['不错吧', '快去买吧！！！'] //只是为了演示
             ,yes: function(){

             }
             ,btn2: function(){
                 // layer.closeAll();
             }

         });


     }

      function shopping(shopid){


        alert("购买成功")

      }




</script>


</body>
</html>
